<template>
  <div class="welcome-container">
    <div class="hero-section">
      <div class="time-badge">
        <i class="time-icon">🕒</i>
        {{ currentTime }}
      </div>
      <div class="hero-content">
        <h1 class="main-title">
          <span class="welcome-text">欢迎来到</span>
          <span class="brand-text">公考同盟</span>
        </h1>
        <p class="hero-subtitle">助力您的公考梦想，一起携手走向成功</p>
      </div>
    </div>

    <div class="content-section">
      <div class="section-header">
        <h2 class="section-title">为什么选择我们？</h2>
        <div class="title-decoration"></div>
      </div>

      <div class="features-grid">
        <div class="feature-card" v-for="(feature, index) in features" :key="index">
          <div class="feature-content">
            <div class="feature-icon-wrapper">
              <span class="feature-icon">{{ feature.icon }}</span>
            </div>
            <div class="feature-text">
              <h3 class="feature-title">{{ feature.title }}</h3>
              <p class="feature-desc">{{ feature.desc }}</p>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, onUnmounted } from 'vue';

const currentTime = ref('');
let timer = null;

const features = ref([
  {
    icon: '📚',
    title: '专业的考试资料',
    desc: '覆盖行测、申论、面试等全科目，持续更新的真题解析',
  },
  {
    icon: '📅',
    title: '系统的学习计划',
    desc: '个性化学习方案，科学规划备考时间，提高学习效率',
  },
  {
    icon: '📢',
    title: '实时的考试动态',
    desc: '第一时间获取考试信息，掌握最新政策变化',
  },
  {
    icon: '👥',
    title: '互助的学习社区',
    desc: '结识志同道合的伙伴，分享经验心得，共同进步',
  },
]);

const updateTime = () => {
  const now = new Date();
  const year = now.getFullYear();
  const month = String(now.getMonth() + 1).padStart(2, '0');
  const day = String(now.getDate()).padStart(2, '0');
  const hours = String(now.getHours()).padStart(2, '0');
  const minutes = String(now.getMinutes()).padStart(2, '0');
  const seconds = String(now.getSeconds()).padStart(2, '0');
  currentTime.value = `${year}年${month}月${day}日 ${hours}:${minutes}:${seconds}`;
};

onMounted(() => {
  updateTime();
  timer = setInterval(updateTime, 1000);
});

onUnmounted(() => {
  if (timer) {
    clearInterval(timer);
  }
});
</script>

<style lang="scss" scoped>
.welcome-container {
  min-height: 100vh;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
  padding: 2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2rem;

  .hero-section {
    width: 100%;
    max-width: 1200px;
    text-align: center;
    position: relative;
    padding: 3rem 2rem;
    background: white;
    border-radius: 24px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);

    .time-badge {
      position: absolute;
      top: 1.5rem;
      right: 1.5rem;
      display: inline-flex;
      align-items: center;
      gap: 0.5rem;
      background: #f1f5f9;
      padding: 0.5rem 1rem;
      border-radius: 50px;
      font-size: 0.9rem;
      color: #64748b;

      .time-icon {
        font-size: 1rem;
        color: #3b82f6;
      }
    }

    .hero-content {
      .main-title {
        margin-bottom: 1.5rem;

        .welcome-text {
          display: block;
          font-size: 1.8rem;
          color: #64748b;
          font-weight: 500;
          margin-bottom: 0.5rem;
        }

        .brand-text {
          display: block;
          font-size: 4rem;
          background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);
          -webkit-background-clip: text;
          -webkit-text-fill-color: transparent;
          font-weight: 800;
          letter-spacing: -1px;
        }
      }

      .hero-subtitle {
        font-size: 1.4rem;
        color: #64748b;
        max-width: 600px;
        margin: 0 auto;
        line-height: 1.5;
      }
    }
  }

  .content-section {
    width: 100%;
    max-width: 1200px;
    padding: 0 2rem;

    .section-header {
      text-align: center;
      margin-bottom: 3rem;

      .section-title {
        font-size: 2.5rem;
        color: #1e293b;
        font-weight: 700;
        margin-bottom: 1rem;
      }

      .title-decoration {
        width: 60px;
        height: 4px;
        background: linear-gradient(90deg, #1d4ed8, #3b82f6);
        margin: 0 auto;
        border-radius: 2px;
      }
    }

    .features-grid {
      display: grid;
      grid-template-columns: repeat(4, 1fr);
      gap: 1.5rem;

      .feature-card {
        background: white;
        border-radius: 16px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.05);
        transition: all 0.3s ease;
        overflow: hidden;
        height: 100%;

        &:hover {
          transform: translateY(-5px);
          box-shadow: 0 8px 30px rgba(0, 0, 0, 0.1);

          .feature-icon-wrapper {
            transform: scale(1.1);
            background: linear-gradient(135deg, #1d4ed8 0%, #3b82f6 100%);

            .feature-icon {
              color: white;
            }
          }
        }

        .feature-content {
          padding: 2rem;
          display: flex;
          flex-direction: column;
          height: 100%;

          .feature-icon-wrapper {
            width: 56px;
            height: 56px;
            background: #f1f5f9;
            border-radius: 12px;
            display: flex;
            align-items: center;
            justify-content: center;
            margin-bottom: 1.5rem;
            transition: all 0.3s ease;

            .feature-icon {
              font-size: 1.8rem;
              color: #3b82f6;
              transition: all 0.3s ease;
            }
          }

          .feature-text {
            flex: 1;
            display: flex;
            flex-direction: column;

            .feature-title {
              font-size: 1.25rem;
              color: #1e293b;
              font-weight: 600;
              margin-bottom: 0.75rem;
            }

            .feature-desc {
              color: #64748b;
              line-height: 1.6;
              font-size: 1rem;
              flex: 1;
            }
          }
        }
      }
    }
  }
}

@media (max-width: 1024px) {
  .welcome-container {
    padding: 1.5rem;

    .content-section {
      .features-grid {
        grid-template-columns: repeat(2, 1fr);
      }
    }
  }
}

@media (max-width: 768px) {
  .welcome-container {
    padding: 1rem;

    .hero-section {
      padding: 2rem 1.5rem;

      .time-badge {
        position: relative;
        top: 0;
        right: 0;
        margin-bottom: 2rem;
      }

      .hero-content {
        .main-title {
          .welcome-text {
            font-size: 1.4rem;
          }

          .brand-text {
            font-size: 3rem;
          }
        }

        .hero-subtitle {
          font-size: 1.2rem;
        }
      }
    }

    .content-section {
      padding: 0 1rem;

      .section-header {
        margin-bottom: 2rem;

        .section-title {
          font-size: 2rem;
        }
      }
    }
  }
}

@media (max-width: 640px) {
  .welcome-container {
    .content-section {
      .features-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
      }
    }
  }
}
</style>
